package com.jic.manager.impl;

import java.lang.Long;
import java.util.List;

import com.jic.manager.entity.SysRoleUser;
import com.jic.manager.mapper.SysRoleUserMapper;
import com.jic.manager.service.SysRoleUserService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 角色用户单关联表
 * @author : 
 * @email : 
 * @since : 2020-02-26 09:38:38
 * @version : v1.0.0
 */
@Service
public class SysRoleUserServiceImpl implements SysRoleUserService{

    @Resource
    private SysRoleUserMapper sysRoleUserMapper;

    @Override
    public long insert(SysRoleUser sysRoleUser) {
        long flag = sysRoleUserMapper.insert(sysRoleUser);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return sysRoleUserMapper.delete(id);
    }

    @Override
    public long update(SysRoleUser sysRoleUser) {
        return sysRoleUserMapper.update(sysRoleUser);
    }

    @Override
    public SysRoleUser queryByPrimaryKey(Long id){
        return sysRoleUserMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<SysRoleUser> query(SysRoleUser sysRoleUser){
        return sysRoleUserMapper.query(sysRoleUser);
    }

    @Override
    public PageResult<SysRoleUser> queryPage(SysRoleUser sysRoleUser, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<SysRoleUser> list = sysRoleUserMapper.queryPage(startIndex, pageQuery.getLimit(), sysRoleUser);
        long count = sysRoleUserMapper.queryPageCount(sysRoleUser);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}